#ifndef SQLITE_H
#define SQLITE_H

#include "head.h"


#define DB_NAME "smart_home.db"
#define TABLE_CLIENTS "clients"     // 在线客户端表
#define TABLE_ACCOUNTS "accounts"   // 用户账号表

// 数据库初始化
sqlite3* Sqlite3_Init();

// 客户端管理
int ClientData_Insert(sqlite3 *db, ClientData data);
int ClientData_GetNameByFd(sqlite3 *db, int fd, char *name);
int ClientData_GetFdByName(sqlite3 *db, const char *name, int *fd);
int ClientData_DeleteByFd(sqlite3 *db, int fd);
int ClientData_GetAllFds(sqlite3 *db, int *fds, int max_size);

// 账号管理
int Account_Register(sqlite3 *db, const char *name, const char *pwd, const char *family_key);
int Account_Login(sqlite3 *db, const char *name, const char *pwd);

#endif